package com.supermap.dataservice.iot;


import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


/**
 * @author aqua
 * @description mapper
 * @date 2018年10月22 上午 11:07
 * @email 1301584033@qq.com
 */
@Mapper
public interface IotUserBindMapper {

    /**
     * 查看物联网是否绑定
     * @param  userId 用户Id
     * retrun Integer
     * */
    @Select("select count(1) from t_vendor_user t where t.userid = #{userId} ")
    Integer getIsBindUserId(@Param("userId") String userId );


    /**
     * 修改密码查看原密码是否正确
     * @param  userId 用户Id
     *@param  loginName
     *@param  password md5
     * retrun Integer
     * */
    @Select("select count(1) from t_vendor_user t where t.userid =#{userId} AND t.w_loginName=#{loginName} and t.w_password=#{password} ")
    Integer getIsPwdBool(@Param("userId") String userId ,@Param("loginName") String loginName,@Param("password") String password);


    /**
     * 查看绑定信息
     * @param  userId 用户Id
     * retrun Integer
     * */
    @Select("select t.id,t.w_loginName,t.w_password,t.vendorid  from t_vendor_user t where t.userid = #{userId} ")
    List<Map<String,Object>> getBindUserId(@Param("userId") String userId );

    /**
     * 遍历所有厂家
     * retrun  List<Map<String,Object>>
     * */
    @Select("select t.id,t.name  from t_vendor t ")
    List<Map<String,Object>> getAllVendor();

    /**
     * 绑定用户
     * @param  vendorid 厂商ID
     * @param  userId 用户Id
     * @param  loginName 账号
     * @param  password 密码
     * retrun Integer
     * */
    @Insert("insert into t_vendor_user(vendorid,userid,w_loginName,w_password) values(#{vendorid},#{userId},#{loginName},#{password})")
    Integer putVendorUser(@Param("vendorid") String vendorid,@Param("userId") String userId,@Param("loginName") String loginName,@Param("password") String password);


    /**
     * 修改账号密码
     * @param  userId 用户Id
     * @param  loginName 账号
     * @param  password 密码
     * retrun Integer
     * */
    @Update("update t_vendor_user set w_loginName=#{loginName},w_password=#{password} where userid = #{userId}")
    Integer saveVendorUser(@Param("userId") String userId,@Param("loginName") String loginName,@Param("password") String password);






}
